<template>
  <div style="text-align: left;">
    <el-steps :active="active" finish-status="success" simple style="margin-top: 20px">
    <el-step title="设置拼团规则" >
    </el-step>
    <el-step title="选择参与商家/店铺">
    </el-step>
    <el-step title="设置参与商品" >
    </el-step>
    <el-step title="拼团活动创建成功" >
    </el-step>
  </el-steps>

    <div class="bottom-btn" v-if="active < 4">
<!--        <el-button v-if="active != 4" :size="size" @click="viewList">取消</el-button>-->
        <el-button :size="size" v-if="active != 1 && active != 4" @click="back">上一步</el-button>
        <!--<el-button :size="size" v-if="active != 0 && active != 2" @click="back">步步</el-button>-->
        <el-button type="primary" v-if="active != 4" :size="size" @click="next">下一步</el-button>
    </div>

    <div v-if="active == 1" class="content">
        <el-form :model="filters" :rules="dataFormRules" ref="filters" :inline="true"
                 :label-position="labelPosition" label-width="120px"  >
            <div>
                <div class="title">
                    基本信息
                </div>
                <div class="item">
                    <el-row>
                        <el-form-item label="拼团名称" prop="promName" class="wid">
                          <el-input v-model="filters.promName" auto-complete="off" type="text" placeholder="请输入3-60个字符之间" maxlength="60" minlength="3" :size="size" class="long"></el-input>

<!--                          <div style="width:100%;">-->
<!--                            <input type="text" v-model="filters.promName" placeholder="拼团名称"/>-->
<!--                          </div>-->
                        </el-form-item>
                    </el-row>
                    <el-row>
                      <el-form-item label="活动时间" prop="promotionStartEndTime" class="wid">
                      <div style="width:100%;">
                        <el-date-picker
                          v-model="filters.promotionStartEndTime"
                          type="datetimerange"
                          range-separator="至"
                          start-placeholder="开始时间"
                          end-placeholder="结束时间"
                          size="mini"
                          :picker-options="startTimePickerOptions"
                          format="yyyy-MM-dd HH:mm:ss"
                          value-format="yyyy-MM-dd HH:mm:ss"
                        ></el-date-picker>
                      </div>
                    </el-form-item>
                    </el-row>
                    <el-row>
                        <div>
                          <el-form-item label="预热时间" prop="preheatTime" class="wid">
                              <input type="text" v-model.number="filters.preheatTime"  maxlength="4"  class="input"  ></input>
                              <span>小时</span>

                          </el-form-item>
                        </div>
                    </el-row>
                    <el-row>
                      <el-form-item label="是否分摊" prop="costAllocationFlag" class="wid">
                        <div style="width:100%;">
                          <el-radio v-model="filters.costAllocationFlag" label="1" value="1" >是</el-radio>
                          <el-radio v-model="filters.costAllocationFlag" label="2" value="2" >否</el-radio>
                          <div v-if="filters.costAllocationFlag == 1">
                            <span>母平台比例</span>
                            <el-input v-model.number="filters.parentAllocationScale" oninput="this.value=this.value.replace(/[^0-9]/g,'');" maxlength="2" auto-complete="off" type="text" :size="size" style="width:70px;"></el-input>
                            <span>%</span>
                            <span style="margin-left:10px;">子平台比例</span>
                            <el-input v-model.number="filters.childAllocationScale" oninput="this.value=this.value.replace(/[^0-9]/g,'');" maxlength="2" auto-complete="off" type="text" :size="size" style="width:70px;"></el-input>
                            <span>%</span>
                            <span style="margin-left:10px;">商家比例</span>
                            <el-input v-model.number="filters.merchantAllocationScale" oninput="this.value=this.value.replace(/[^0-9]/g,'');" maxlength="2" auto-complete="off" type="text" :size="size" style="width:70px;"></el-input>
                            <span>%</span>
                            <span style="margin-left:10px;">店铺比例</span>
                            <el-input v-model.number="filters.storeAllocationScale" oninput="this.value=this.value.replace(/[^0-9]/g,'');" maxlength="2" auto-complete="off" type="text" :size="size" style="width:70px;"></el-input>
                            <span>%</span>
                          </div>
                        </div>
                      </el-form-item>
                    </el-row>
                  <!--  添加标签相关页面1 开始 -->
                    <el-row>
                      <el-form-item label="活动标签" prop="labelId" class="wid">
                        <el-select v-model="filters.labelId" placeholder="请选择" size="mini">
                          <el-option
                            v-for="item in tagsList"
                            :key="item.id"
                            :label="item.tagName"
                            :value="item.id">
                          </el-option>
                        </el-select>
                        <el-button type="primary" @click="addtags" size="mini">添加标签</el-button>
                      </el-form-item>
                    </el-row>
                  <!--  添加标签相关页面1 结束 -->
                </div>
            </div>
            <div>
                <div class="title">
                    活动规则
                </div>
                <div class="item">
                    <el-row>
                        <el-form-item label="团单时长" prop="groupTimeType" class="wid">
                            <div style="width:100%;">
                                <el-radio v-model="filters.groupTimeType" label="0">不限</el-radio>
                                <el-radio v-model="filters.groupTimeType" label="1">限</el-radio>
                                <input type="text" v-model="filters.groupTimeLimit" placeholder="团单时长时间" v-if="filters.groupTimeType == '1'" class="input" oninput="this.value=this.value.replace(/[^0-9]/g,'');"/>
                                <!-- <el-input v-model="dataForm.团单时长时间" auto-complete="off" type="text" placeholder="团单时长时间" :size="size" v-if="dataForm.团单时长 == '2'"></el-input> -->
                                <span v-if="filters.groupTimeType == '1'">小时</span>
                            </div>
                        </el-form-item>
                    </el-row>
                    <el-row>
                        <el-form-item label="自动成团设置" class="wid">
                            <div style="width:100%;">
                                <span>距结束 </span>
                                <input type="text" v-model="filters.autoCompleteTime" class="input" oninput="this.value=this.value.replace(/[^0-9]/g,'');"/>
                                <span>小时未成团则自动成团 </span>
                                <el-tooltip effect="dark" content="距离拼团活动结束时间XX小时未成团的拼团单可自动成团" placement="right">
                                    <!-- <el-button>左下</el-button> -->
                                    <i class="el-icon-warning-outline" style="padding-left:5px;font-size: 15px;"></i>
                                </el-tooltip>
                            </div>
                        </el-form-item>
                    </el-row>
                    <el-row>
                        <el-form-item label="单用户参团限制" prop="individualJoinType" class="wid">
                            <div style="width:100%;">
                                <el-radio v-model="filters.individualJoinType" label="0">不限</el-radio>
                                <el-radio v-model="filters.individualJoinType" label="1">限</el-radio>
                                <input type="text" v-model="filters.individualJoinTime" v-if="filters.individualJoinType == '1'" class="input"/>
                                <!-- <el-input v-model="dataForm.团单时长时间" auto-complete="off" type="text" placeholder="团单时长时间" :size="size" v-if="dataForm.团单时长 == '2'"></el-input> -->
                                <span v-if="filters.individualJoinType == '1'">次</span>
                            </div>
                        </el-form-item>
                    </el-row>
                    <el-row>
                        <el-form-item label="是否包邮" prop="mailType" class="wid">
                            <div style="width:100%;">
                                <el-radio v-model="filters.mailType" label="1">是</el-radio>
                                <el-radio v-model="filters.mailType" label="0">否</el-radio>
                            </div>
                        </el-form-item>
                    </el-row>
                    <el-row>
                        <el-form-item label="拼团人数" prop="groupMembers" class="wid">
                            <div style="width:100%;">
                               <el-input v-model="filters.groupMembers" auto-complete="off" type="text" placeholder="拼团人数/人" :size="size" oninput="this.value=this.value.replace(/[^0-9]/g,'');"></el-input>
                            </div>
                        </el-form-item>
                    </el-row>
<!--                    <el-row>-->
<!--                        <el-form-item label="拼团模式" prop="groupType" class="wid">-->
<!--                            <div style="width:100%;">-->
<!--                                <el-radio v-model="filters.groupType" label="0">单品团</el-radio>-->
<!--                            </div>-->
<!--                        </el-form-item>-->
<!--                    </el-row>-->
<!--                    <el-row>-->
<!--                        <el-form-item label="活动图片" class="wid">-->
<!--                            <div style="width:100%;padding:10px;border: 1px solid #c0ccda;">-->
<!--                                <el-upload-->
<!--                                    action="https://jsonplaceholder.typicode.com/posts/"-->
<!--                                    list-type="picture-card"-->
<!--                                    :on-preview="handlePictureCardPreview"-->
<!--                                    :on-remove="handleRemove">-->
<!--                                    <i class="el-icon-plus"></i>-->
<!--                                </el-upload>-->
<!--                            </div>-->
<!--                        </el-form-item>-->
<!--                    </el-row>-->
                  <!-- 上传图片相关页面 开始  -->
                    <el-row>
                      <el-form-item label="活动图片" class="wid">
                        <div style="width: 775px;border: 1px solid rgb(162, 162, 162);height: 300px;overflow-y: auto;display: flex;flex-wrap: wrap;">
                          <div class="img-card" v-for="(item, index) in imgUrlList" :key="index" @mouseleave="mouseLeave(index)" @mouseenter="mouseEnter(index)">
                            <img :src="item.url" style="width: 100%;height: 100%;"/>
                            <span class="el-upload-list-item-actions" :class="imgUrlList[index].hover != null ? 'el-upload-list-item-actions-hover' : '' ">
                                          <span class="el-upload-list__item-preview upload-delete" @click="deleteImgUrlList(index)">
                                              <i class="el-icon-delete"></i>
                                          </span>
                              <!-- <span class="el-upload-list__item-delete">

                              </span> -->
                                      </span>
                          </div>
                          <div tabindex="0" class="el-upload el-upload--picture-card img-card-upload" @click="selectUploadMethod">
                            <i data-v-5410c7af="" class="el-icon-plus"></i>
                          </div>
                        </div>
                      </el-form-item>
                    </el-row>

                  <!-- 上传图片相关页面 结束  -->
                </div>
            </div>
            <div>
                <div class="title">
                    参与条件
                </div>
                <div class="item">

                  <el-row>
                    <el-form-item label="开团活动对象" prop="customerLimit" class="wid">
                      <div style="width:100%;">
                        <el-checkbox
                          :indeterminate="isIndeterminate9"
                          v-model="checkAll9"
                          @change="handleCheckAllChange9"
                        >全选</el-checkbox>
                        <el-checkbox-group v-model="filters.customerLimit" @change="handleCheckedCitiesChange9">
                          <el-checkbox v-for="userType in customerLimitRadios" :label="userType.code" :key="userType.code">{{userType.name}}</el-checkbox>
                        </el-checkbox-group>
                      </div>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="参团活动对象" prop="offeredCustomerLimit" class="wid">
                      <div style="width:100%;">
                        <el-checkbox
                          :indeterminate="isIndeterminate10"
                          v-model="checkAll10"
                          @change="handleCheckAllChange10"
                        >全选</el-checkbox>
                        <el-checkbox-group v-model="filters.offeredCustomerLimit" @change="handleCheckedCitiesChange10">
                          <el-checkbox v-for="userType in offeredCustomerLimitRadios" :label="userType.code" :key="userType.code">{{userType.name}}</el-checkbox>
                        </el-checkbox-group>
                      </div>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="使用渠道" prop="channelIds" class="wid" style="margin-top: 40px">
                      <div style="width:100%;">
                        <el-tree :data="channelList" :props="channlProps" v-model="filters.channelCodes"
                                 show-checkbox @check-change="channelCheckChange"></el-tree>
                      </div>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="新老用户" prop="proUserType" class="wid">
                      <div style="width:100%;">
                        <el-checkbox
                          :indeterminate="isIndeterminate2"
                          v-model="checkAll2"
                          @change="handleCheckAllChange2"
                        >全选</el-checkbox>
                        <el-checkbox-group v-model="filters.proUserType" @change="handleCheckedCitiesChange2">
                          <el-checkbox v-for="userType in proUserTypeRadios" :label="userType.code" :key="userType.code">{{userType.name}}</el-checkbox>
                        </el-checkbox-group>
                      </div>
                    </el-form-item>
                  </el-row>
<!--                   <el-row>-->
<!--                        <el-form-item label="活动渠道" prop="活动渠道" class="wid">-->
<!--                            <div style="width:100%;">-->
<!--                                <el-radio v-model="filters.channelCodes" label="110001">BBC</el-radio>-->
<!--                                <el-radio v-model="filters.channelCodes" label="110002">B2C</el-radio>-->
<!--                                <el-radio v-model="filters.channelCodes" label="110003">B2B</el-radio>-->
<!--                                <el-radio v-model="filters.channelCodes" label="110004">O&O</el-radio>-->
<!--                            </div>-->
<!--                        </el-form-item>-->
<!--                   </el-row>-->
                  <el-row>
                    <el-form-item label="店铺地区" class="wid">
                      <div style="width:100%;" >
                        <el-radio-group v-model="filters.storeArea">
                          <el-radio :label="3" class="form-radio">全国</el-radio>
                        </el-radio-group>
                      </div>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="用户地区" class="wid">
                      <div style="width:100%;">
                        <el-radio-group v-model="filters.userArea">
                          <el-radio :label="3" class="form-radio">全国</el-radio>
                        </el-radio-group>
                      </div>
                    </el-form-item>
                  </el-row>
                   <el-row>
                        <el-form-item label="备注" class="wid" prop="remark">
                            <div style="width:100%;">
                               <el-input
                                    type="textarea"
                                    :rows="4"
                                    placeholder="请输入备注"
                                    v-model="filters.remark">
                                </el-input>
                            </div>
                        </el-form-item>
                   </el-row>
<!--                   <el-row>-->
<!--                     <el-form-item label="是否保存为模板" class="wid">-->
<!--                       <el-checkbox v-model="filters.templateSaveFlag" @change="setTemplateSaveFlag">是</el-checkbox>-->
<!--                     </el-form-item>-->
<!--                   </el-row>-->
<!--                    <el-row>-->
<!--                      <el-form-item label="模板名称" prop="templateName" class="wid">-->
<!--                          <el-input v-model="filters.templateName" type="text" placeholder="模板名称" :size="size" class="long"></el-input>-->
<!--                      </el-form-item>-->
<!--                    </el-row>-->
                </div>
            </div>
        </el-form>
    </div>
    <div v-if="active == 2" class="content">
      <!-- 添加商家 -->
      <el-tabs type="border-card" style="margin-top: 15px;">
        <el-tab-pane label="商家">
          <div style="float: left;margin-bottom: 10px;"  >
            <el-button type="primary" size="mini" @click="querySupplierListForAdd()">添加商家</el-button>
            <el-button type="danger" size="mini" @click="delAllSelectedSuppliermerchantTableData2()">批量删除</el-button>
          </div>
          <el-table :data="merchantTableData2" border style="width: 100%"  @selection-change="merchantTableData2selectionChange"
          >
            <el-table-column type="selection"></el-table-column>
            <el-table-column prop="id" label="商品编号">
              <template slot-scope="scope">
                <span>{{ scope.row.orgNumber}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="merchantName" label="商家名称">
              <template slot-scope="scope">
                <span>{{ scope.row.merchantName}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="merchantTypeManager" label="组织分类" align="center">
              <template slot-scope="scope">
                <span v-if="scope.row.merchantTypeManager == '1'">自营商家</span>
                <span v-else-if="scope.row.merchantTypeManager == '2'">第三方商家</span>
              </template>
            </el-table-column>
            <el-table-column label="操作"   >
              <template slot-scope="scope">
                <el-button  type="text" class="textButton" @click="merchantTableData2delete(scope.row.id)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
          <!--分页栏-->
          <div class="toolbar" style="padding:10px;">
            <el-pagination
              layout="total, sizes, prev, pager, next, jumper"
              @current-change="mainMerchantRefreshPageRequest"
              :current-page="mainMerchantForm.pageNo"
              :page-size="mainMerchantForm.pageSize"
              :total="mainMerchantTableDataTatol"
              style="float:right;"
              :page-sizes="[10, 20, 30, 40]"
              @size-change="mainMerchantHandleSizeChange"
            ></el-pagination>
          </div>
        </el-tab-pane>


        <el-tab-pane label="店铺">
          <div style="float: left;margin-bottom: 10px;"  >
            <el-button type="primary" size="mini" @click="querySupplierListForAdd2()">添加店铺</el-button>
            <el-button type="danger" size="mini" @click="delAllSelectedSupplierstoreTableData()">批量删除</el-button>
          </div>
          <el-table :data="storeTableData" border style="width: 100%"  @selection-change="storeTableDataselectionChange">
            <el-table-column type="selection"></el-table-column>
            <el-table-column label="店铺编号">
              <template slot-scope="scope">
                <span>{{ scope.row.storecode}}</span>
              </template>
            </el-table-column>
            <el-table-column  label="店铺名称">
              <template slot-scope="scope">
                <span>{{ scope.row.storename}}</span>
              </template>
            </el-table-column>
            <el-table-column  label="店铺类型">
              <template slot-scope="scope">
                <span v-if="scope.row.storeType =='1'">线上店铺</span>
              </template>
            </el-table-column>
            <el-table-column  label="操作"   >
              <template slot-scope="scope">
                <el-button  type="text" class="textButton"  @click="storeDelete(scope.row.id)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
          <!--分页栏-->
          <div class="toolbar" style="padding:10px;">
            <el-pagination
              layout="total, sizes, prev, pager, next, jumper"
              @current-change="mainSroreMerchantRefreshPageRequest"
              :current-page="mainStoreMerchantForm.pageNo"
              :page-size="mainStoreMerchantForm.pageSize"
              :total="storeTableDataTatol"
              style="float:right;"
              :page-sizes="[10, 20, 30, 40]"
              @size-change="mainSroreMerchantHandleSizeChange"
            ></el-pagination>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <!--step3##111start-->
    <!--促销商品列表-->
    <div v-if="active == 3" class="content">
        <el-form :inline="true" class="demo-form-inline2" size="small">
            <el-form-item>
                <el-button type="primary" @click="add">添加促销商品</el-button>
            </el-form-item>
          <!-- 批量删除促销商品 -->
            <el-form-item>
              <el-button type="danger" plain @click="promotionProductDeleteBatch">批量删除</el-button>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="searchMerchantProductFlag = !searchMerchantProductFlag">搜索</el-button>
<!--              <el-button type="primary" @click="editMerchantProductFlag = !editMerchantProductFlag">批量编辑</el-button>-->
            </el-form-item>
          <el-form-item>
            <!--  <el-button icon="el-icon-document" size="mini" type="primary" @click="downloadTemplate">模板下载</el-button>-->
            <el-upload  class="avatar-uploader"
                        :show-file-list="true"
                        accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
                        :limit=limitNum
                        :auto-upload="true"
                        :action="UploadUrl()"
                        :http-request="uploadFile"
                        :before-upload="beforeUploadFile"
                        :on-change="fileChange"
                        :on-exceed="exceedFile"
                        :on-success="handleSuccess"
                        :on-error="handleError"
                        :file-list="fileList">
              <el-button icon="el-icon-document-add" size="mini" type="primary"

              >商品导入</el-button>
            </el-upload>
          </el-form-item>
        </el-form>
        <!--  促销商品搜索框 -->
        <div v-if="searchMerchantProductFlag">
          <el-form :inline="true" :model="mainProductForm" size="mini" ref="mainProductForm">
            <el-form-item  label="商家" prop="merchantId">
              <template>
                <el-select v-model="mainProductForm.merchantId" placeholder="请选择">
                  <el-option
                    v-for="item in merchantTableData2"
                    :key="item.merchantId"
                    :label="item.merchantName"
                    :value="item.merchantId">
                  </el-option>
                </el-select>
              </template>
            </el-form-item>
            <el-form-item label="商品编码" prop="mpCode">
              <el-input v-model="mainProductForm.mpCode"></el-input>
            </el-form-item>
            <el-form-item label="商品名称" prop="mpName">
              <el-input v-model="mainProductForm.mpName"></el-input>
            </el-form-item>
            <el-form-item label="商品分类" prop="categoryName">
              <el-input v-model="mainProductForm.categoryName"></el-input>
            </el-form-item>
            <el-form-item  prop="mpName">
              <el-button type="primary" size="mini" @click="mainProductTableDataFormFind()">查询</el-button>
              <el-button type="primary" size="mini" @click="resetForm('mainProductForm')">重置</el-button>
            </el-form-item>

          </el-form>
        </div>
        <div class="table-section">
            <el-table :data="merchantProductTableData"
                :header-cell-style="tableHeaderColor"
                ref="multipleTable"
                      @selection-change="addSelectionChangeMainProduct"
                style="width: 100%"
                :row-class-name="tableRowClassName"
                border
                :size="size">
                <el-table-column
                  type="selection"
                  width="55">
                </el-table-column>
                <el-table-column prop="mpCode" label="商品编码" width="180" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.mpCode}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="productName" label="商品名称" width="180" sortable align="center">
                    <template slot-scope="scope">
                      <span>{{ scope.row.mpName}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="categoryName" label="商品分类" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.categoryName}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="merchantName" label="商家名称" align="center">
                    <template slot-scope="scope">
                      <span>{{ scope.row.merchantName}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="storeName" label="店铺名称" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.storeName}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="salePriceWithTax" label="零售价（元）" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.salePriceWithTax}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="grouponPrice" label="拼团价（元）" align="center"  >
                    <template slot-scope="scope">
                           <el-input v-model="scope.row.grouponPrice"
                                     :size="size"  @blur="updatePriceOrLimit(scope.row)" />
                    </template>
                </el-table-column>
                <el-table-column prop="ChannelMerchantLimit" label="商家单渠道限购" align="center"  >
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.channelMerchantLimit"
                              :size="size"  @blur="updatePriceOrLimit(scope.row)" />
                  </template>
                </el-table-column>
                <el-table-column prop="channelStoreLimit" label="店铺单渠道限购" align="center"  >
                    <template slot-scope="scope">
                           <el-input v-model="scope.row.channelStoreLimit" oninput="value=value.replace(/[^\d\.]/g,'')"
                                     :size="size"  @blur="updatePriceOrLimit(scope.row)" />
                    </template>
                </el-table-column>
              <el-table-column prop="channelIndividualLimit" label="个人单渠道限购" align="center"  >
                <template slot-scope="scope">
                  <el-input v-model="scope.row.individualLimit" oninput="value=value.replace(/[^\d\.]/g,'')"
                            :size="size"  @blur="updatePriceOrLimit(scope.row)" />
                </template>
              </el-table-column>
                <!-- <el-table-column
                    prop="tag"
                    label="标签"
                    width="100"
                    filter-placement="bottom-end"
                    align="center">
                        <template slot-scope="scope">
                            <el-tag
                                :type="scope.row.tag === '学校' ? 'primary' : 'success'"
                                disable-transitions>{{scope.row.tag}}
                            </el-tag>
                        </template>
                </el-table-column> -->
                <el-table-column label="操作" fixed="right" align="center" width="200">
                  <template slot-scope="scope">
<!--                      <el-button-->
<!--                        v-show="scope.row.disabled"-->
<!--                        :size="size"-->
<!--                        icon="el-icon-edit"-->
<!--                        @click="handleEdit(scope.$index, scope.row)" >编辑</el-button>-->
<!--                      <el-button-->
<!--                        v-show="!scope.row.disabled"-->
<!--                      :size="size"-->
<!--                      icon="el-icon-edit"-->
<!--                      type="primary"-->
<!--                      @click="handleSave(scope.$index, scope.row)" >保存</el-button>-->
                      <el-button
                        @click.native.prevent="delMerchantProducts(scope.row,scope.row.promotionId,scope.row.mpId)"
                        type="text"
                        size="small">
                        删除
                      </el-button>
                  </template>
                </el-table-column>
            </el-table>
<!--          <div style="margin-top: 10px;">-->
<!--            <el-button size="mini" type="primary" @click="mainProductTableDataFormFind()">查询促销商品</el-button>-->
<!--          </div>-->
          <div v-if="merchantProductTableData.length > 0" style="text-align:center">
            <el-pagination
              @size-change="mainProductHandleSizeChange"
              @current-change="mainProductHandleCurrentChange"
              :current-page="mainProductForm.start"
              :page-sizes="[10]"
              :page-size="mainProductForm.limit"
              layout="total, sizes, prev, pager, next, jumper"
              :total="merchantProductTableDataTotal">
            </el-pagination>
          </div>
        </div>
<!--        <div v-if="merchantProductTableData.length > 0" style="position:absolute;right:20px;bottom:10px;">-->


    </div>
    <!--step3##111end-->
    <div v-if="active == 4" class="content" style="text-align: center;margin-top: 5%;">
        <div>
            <img src="/static/images/success.png" style="width:20px;"/>
            <span style="font-size:25px;">拼团活动创建成功!</span>
        </div>
        <div style="margin-top:20px;" v-if="shenhe == 0">
            <el-button type="primary" plain :size="size" @click="shenheHuodong(0)">提交审核</el-button>
        </div>
        <div style="margin-top:20px;" v-if="shenhe == 1">
            <el-button type="primary" plain :size="size" @click="shenheHuodong(1)">审核</el-button>
        </div>
        <div style="margin-top:20px;" v-if="saveTemplateFlag == 0">
<!--        <div style="margin-top:20px;" >-->
          <el-button type="primary" plain :size="size" @click="saveTemplateModal">保存为模板</el-button>
        </div>
        <div style="margin-top:20px;">
            <el-link type="primary" @click="detailList">查看活动列表</el-link>
        </div>
    </div>

    <!--step2###start-->
    <!-- 添加商家对话框 -->
    <el-dialog :title="'添加商家'" width="40%" :visible.sync="editDialogVisible" :close-on-click-modal="false" >
      <div>
        <div>
          <el-form :inline="true" :model="merchantForm"  size="mini" ref="merchantForm">
            <el-form-item label="商家编号" label-width="100px" prop="orgNumber">
              <el-input v-model="merchantForm.orgNumber" placeholder="" size="mini"></el-input>
            </el-form-item>
            <el-form-item label="商家名称" label-width="100px" prop="name">
              <el-input v-model="merchantForm.name" placeholder="" size="mini"></el-input>
            </el-form-item>
          </el-form>
          <el-button  size="mini" @click="merchantFormFind()">查询</el-button>
          <el-button  size="mini" @click="resetForm('merchantForm')">重置</el-button>
        </div>
        <div style="padding-top: 45px;">
          <el-table :data="merchantTableData" border style="width: 100%" @selection-change="addSelectionChange">
            <el-table-column type="selection"></el-table-column>
            <el-table-column width="285px" align="center" label="商家ID">
              <template slot-scope="scope">
                <span>{{ scope.row.id}}</span>
              </template>
            </el-table-column>
            <el-table-column width="389px" align="center" label="商家名称">
              <template slot-scope="scope">
                <span>{{ scope.row.name}}</span>
              </template>
            </el-table-column>

          </el-table>
          <!--分页栏-->
          <div class="toolbar" style="padding:10px;">
            <el-pagination
              layout="total, sizes, prev, pager, next, jumper"
              @current-change="refreshPageRequest"
              :current-page="merchantForm.start"
              :page-size="merchantForm.limit"
              :total="merchantTableDataTatol"
              style="float:right;"
              :page-sizes="[10, 20, 30, 40]"
              @size-change="merchantHandleSizeChange"
            ></el-pagination>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button :size="size" @click.native="editDialogVisible = false">取消</el-button>
        <el-button :size="size"  type="primary"  @click.native="editDialogVisible = false" @click="merchantTableDataSubmit">确定</el-button>
      </div>
    </el-dialog>
    <!-- 添加店铺对话框 -->
    <el-dialog :title="'添加参与店铺'" width="60%" :visible.sync="editDialogVisible2" :close-on-click-modal="false" >
      <div>
        <div>
          <el-form :inline="true" :model="storeForm" size="mini" ref="storeForm">
            <el-form-item label="店铺ID" label-width="100px" prop="storeId">
              <el-input v-model="storeForm.storeId" placeholder="" size="mini"></el-input>
            </el-form-item>
            <el-form-item label="店铺名称" label-width="100px" prop="storeName">
              <el-input v-model="storeForm.storeName" placeholder="" size="mini"></el-input>
            </el-form-item>
          </el-form>
          <el-button  size="mini" @click="storeFormFind()">查询</el-button>
          <el-button  size="mini" @click="resetForm('storeForm')">重置</el-button>
        </div>
        <div style="padding-top: 45px;">
          <el-table :data="storeTableData2" border style="width: 100%" @selection-change="storeTableData2AddSelectionChange">
            <el-table-column type="selection"></el-table-column>
            <el-table-column prop="id" label="店铺ID">
              <template slot-scope="scope">
                <span>{{ scope.row.id}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="storeName" label="店铺名称">
              <template slot-scope="scope">
                <span>{{ scope.row.storeName}}</span>
              </template>
            </el-table-column>
          </el-table>
          <!--分页栏-->
          <div style="margin-top: 40px;text-align: center">
            <el-pagination
              layout="total, sizes, prev, pager, next, jumper"
              @current-change="refreshPageRequestStore"
              :current-page="storeForm.start"
              :page-size="storeForm.limit"
              :total="storeTableData2Total"
              style="float:right;"
              :page-sizes="[10, 20, 30, 40]"
              @size-change="handleSizeChangeStore"
            ></el-pagination>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button :size="size" @click.native="editDialogVisible2 = false">取消</el-button>
        <el-button :size="size"  type="primary"  @click.native="editDialogVisible2 = false"
                   @click="storeTableData2Click">确定</el-button>
      </div>
    </el-dialog>
    <!--step2###end-->


    <el-dialog :visible.sync="dialogVisible">
        <img width="100%" :src="dialogImageUrl" alt="">
    </el-dialog>
    <!--setp##-&#45;&#45;111start-->
    <!-- 添加商品对话框 -->
    <el-dialog :visible.sync="dialogVisibleTwo" width="85%" title="添加商品">
      <!--<div slot="footer" class="dialog-footer" style="text-align:center">-->
        <!--<el-button :size="size" @click.native="dialogVisibleTwo = false">取消</el-button>-->
        <!--<el-button :size="size" type="primary" @click.native="dialogVisibleTwo = false"-->
                   <!--@click="productTableData2Click" :loading="productEditLoading">确定</el-button>-->
      <!--</div>-->
        <el-tabs v-model="tabsIndex">
            <el-tab-pane label="商品管理" name="first">
              <el-form :inline="true" :model="productForm"  label-width="90px" ref="productForm" :size="size">
<!--                <div class="col-sm-9">-->
                <el-form-item label="商品名称" prop="chineseName">
                  <el-input v-model="productForm.chineseName" auto-complete="off"></el-input>
                </el-form-item>
<!--                </div>-->
                <el-form-item label="商品ID" prop="id">
                  <el-input v-model="productForm.id" auto-complete="off"></el-input>
                </el-form-item>

                <el-form-item label="店铺名称" prop="storeName">
                  <el-input v-model="productForm.storeName" auto-complete="off"></el-input>
                </el-form-item>

                <el-form-item label="商家名称" prop="merchantName">
                  <el-input v-model="productForm.merchantName" auto-complete="off"></el-input>
                </el-form-item>
                <!--<div class="col-sm-9">-->
                  <!--<el-form-item label="商品条码" prop="barCode">-->
                    <!--<el-input v-model="productForm.barCode" auto-complete="off"></el-input>-->
                  <!--</el-form-item>-->
                <!--</div>-->
                <!--<div class="col-sm-9">-->
                  <!--<el-form-item label="商品类别" prop="categoryId">-->
                    <!--<TreeSelect :props="props" :options="optionData" :value="valueId" :clearable="isClearable" :accordion="isAccordion" @getValue="getValue($event)" @check-change="handleCheckChange"/>-->
                  <!--</el-form-item>-->
                <!--</div>-->
                <!--<div class="col-sm-9">-->
                  <!--<el-form-item label="商品品牌" prop="value6">-->
                    <!--<el-select v-model="value6" multiple placeholder="请选择" collapse-tags>-->
                      <!--<el-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value">-->
                      <!--</el-option>-->
                    <!--</el-select>-->
                  <!--</el-form-item>-->
                <!--</div>-->
                <!--<div class="col-sm-9">-->
                  <!--<el-form-item label="商家名称" prop="value5">-->
                    <!--<el-select v-model="value5" multiple placeholder="请选择" collapse-tags>-->
                      <!--<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">-->
                      <!--</el-option>-->
                    <!--</el-select>-->
                  <!--</el-form-item>-->
                <!--</div>-->
                <div class="col-sm-9" style="text-align: center">
                  <el-button  size="mini" @click="productFormFind()">查询</el-button>
                  <el-button  size="mini" @click="resetForm('productForm')">重置</el-button>
                </div>

              </el-form>

                <div class="line line-dashed b-b line-lg  ng-scope"></div>
                <!--  商品列表 v-loading="productListloading"-->
                <div class="table-section" style="margin-top: 20px">
                    <el-table
                        :data="tableDataTwo"
                        @selection-change="addSelectionChangeProduct"
                        :header-cell-style="tableHeaderColor"
                        ref="multipleTable"
                        style="width: 100%"
                        :row-class-name="tableRowClassName"
                        border
                        :size="size">
                      <el-table-column
                        type="selection"
                        width="55">
                      </el-table-column>
                      <!-- <el-table-column prop="pictureUrl" label="主图" showImg="true"  align="center">
            <template slot-scope="scope">
              　<img :src="scope.row.pictureUrl" width="30" height="30"/>
            </template>
          </el-table-column> -->
                      <el-table-column prop="id" label="商品ID" sortable  align="center"></el-table-column>
                      <el-table-column prop="chineseName" label="商品名称" align="center"></el-table-column>
                      <el-table-column prop="fullNamePath" label="商品分类" align="center"></el-table-column>
                      <el-table-column prop="merchantName" label="商家名称" align="center"></el-table-column>
                      <el-table-column prop="merchantName" label="店铺名称" align="center"></el-table-column>
                      <el-table-column prop="salePriceWithTax" label="原价（元）" align="center"></el-table-column>
                      <!-- <el-table-column label="操作" fixed="right" align="center">
                        <template slot-scope="scope">
                          <el-button
                            :size="size"
                            @click="select(scope.row)">选择</el-button>
                        </template>
                      </el-table-column> -->
                    </el-table>
                </div>
<!--              <div v-if="tableDataTwo.length > 0" style="position:absolute;right:20px;bottom:10px;">-->
              <div v-if="tableDataTwo.length > 0" style="margin-top: 40px;text-align: center">
                <el-pagination
                  @size-change="producthandleSizeChange"
                  @current-change="producthandleCurrentChange"
                  :current-page="productForm.start"
                  :page-sizes="[10, 20, 30, 40]"
                  :page-size="productForm.limit"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="productListTotal">
                </el-pagination>
              </div>

            </el-tab-pane>
        </el-tabs>
        <div slot="footer" class="dialog-footer" style="text-align: center">
          <span>已选择<i style="font-style: inherit;margin-left: 5px;margin-right: 5px;color: #2F4554;">{{productAddSelection.length}}</i>件商品</span>
          <el-button @click="dialogVisibleTwo=false" size="mini">取消</el-button>
          <el-button type="primary" @click="addProductChange" size="mini">确定</el-button>
        </div>
    </el-dialog>
    <!--setp##-&#45;&#45;111end-->

    <!--审核弹框-->
    <el-dialog title="管理员备注" width="50%" :visible.sync="dialogVisibleAdmin" @closed="closedAuditDialog" :close-on-click-modal="false">
      <el-form :model="adminDataForm" :rules="adminDataFormRules" ref="adminDataForm" label-width="100%" :size="size"
               label-position="right" inline>
        <el-form-item prop="auditRemark">
          <div style="width:100%;">
            <el-input
              type="textarea"
              placeholder="请输入备注"
              v-model="adminDataForm.auditRemark">
              :rows="4"
            </el-input>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button :size="size" @click.native="submitFormAdminNotPass" type="primary">不通过</el-button>
        <el-button :size="size" type="primary" @click.native="submitFormAdmin">通过</el-button>
      </div>
    </el-dialog>

    <!--  添加标签相关页面2 开始 -->
    <el-dialog title="添加标签" :visible.sync="addTagDialogFormVisible" width="20%">
      <el-form :model="addTagForm" :rules="addTagRules" ref="addTagForm">
        <el-form-item label="标签分类" :label-width="formLabelWidth" prop="categoryId">
          <el-select style="width:200px" v-model="addTagForm.categoryId" placeholder="请选择分类标签" size="mini">
            <el-option
              v-for="(item, index) in tagCategoryList"
              :key="index"
              :label="item.categoryName"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="标签名称" :label-width="formLabelWidth" prop="tagName">
          <el-input style="width:200px" placeholder="请输入标签名称" v-model.trim="addTagForm.tagName" size="mini"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="addTagDialogFormVisible=false" size="mini">取消</el-button>
        <el-button type="primary" @click="addNewTag" size="mini">确定</el-button>
      </div>
    </el-dialog>

    <!--  添加标签相关页面2 结束 -->

    <!-- 上传图片相关页面2 开始  -->
    <el-dialog title="上传图片选择" :visible.sync="uploadMethodVisible" width="20%">
	    <span>
          <el-upload
            class="upload-demo el-upload-dragger-update"
            drag
            action="https://jsonplaceholder.typicode.com/posts/"
            :on-success="imgUploadSuccess"
            :on-error="imgUploadError"
            :show-file-list='showFileList'
            :auto-upload="autoUpload"
            :http-request="uploadMethod">
            <el-button type="primary" style="width:300px;">本地上传</el-button>
          </el-upload>
          <div style="width:360px;text-align: center;margin-left: -10px;">
              <el-button type="primary" style="width:300px;" @click="materialLibraryVisible=true">素材库上传</el-button>
          </div>
      </span>
    </el-dialog>

    <!-- 素材库 -->
    <el-dialog title="选择图片" :visible.sync="materialLibraryVisible" width="61%">
      <div>
        <el-container>
          <el-aside width="240px" class="el-aside-Superior">
            <el-tabs v-model="treeActiveName" type="border-card" @tab-click="handleClick" :stretch="stretch">
              <el-tab-pane label="我的素材" name="1">
                <el-tree :data="localTreeList" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
              </el-tab-pane>
              <el-tab-pane label="平台素材" name="2">
                <el-tree :data="deptTreeList" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
              </el-tab-pane>
            </el-tabs>
          </el-aside>
          <el-main>
            <div class="material-main">
              <div class="material-header">
                <div class="material-title-left">
                  {{materialTitle}}
                </div>
                <div class="material-title-right" v-if="materialQueryPageFilters.categoryId != null">
                  <el-input type="text" v-model="materialQueryPageFilters.materialName" placeholder="请输入素材名称" size="mini" style="width:180px"></el-input>
                  <el-button type="primary" size="mini" @click="handleNodeClick">搜索</el-button>
                </div>
              </div>
              <div class="material-main-list">
                <!-- <div :class="[materialList[index].isSelect == true ? 'material-main-item-name-select material-main-item' : 'material-main-item']" v-for="(item , index) in materialList" :key="index" @click="selectMaterial(index)"> -->
                <div class="material-main-item" :class="[materialList[index].isSelect == true ? 'material-main-item-select' : '']" v-for="(item , index) in materialList" :key="index" @click="selectMaterial(index)">
                  <div class="material-main-item-img">
                    <img :src="item.materialUrl" style="width:100%;height: 100%;"/>
                  </div>
                  <div class="material-main-item-name">
                    {{item.materialName}}
                  </div>
                </div>
                <div v-if="materialList.length < 1" style="text-align: center;width: 100%;">
                  暂无数据
                </div>
              </div>
              <div v-if="materialList.length > 0" style="position:absolute;right:20px;bottom:10px;">
                <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="materialQueryPageFilters.start"
                  :page-sizes="[10]"
                  :page-size="materialQueryPageFilters.limit"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="materialListTotal">
                </el-pagination>
              </div>
            </div>
          </el-main>
        </el-container>
      </div>
      <div slot="footer" class="dialog-footer">
        <span>已选择<i style="font-style: inherit;margin-left: 5px;margin-right: 5px;color: #2F4554;">{{materialImgNumber}}</i>张图片</span>
        <el-button @click="materialLibraryVisible=false" size="mini">取消</el-button>
        <el-button type="primary" @click="addMaterial" size="mini">确定</el-button>
      </div>
    </el-dialog>

    <!-- 上传图片相关页面2 结束  -->

    <!--保存模板弹窗-->
    <el-dialog title="模板名称设置" width="30%" :visible.sync="templateDialogVisible" :close-on-click-modal="false">
      <el-form :model="templateDataForm" label-width="80px" :size="size" :rules="templateDataFormRule">
        <el-form-item label="模板名称" prop="templateName">
          <el-input
            placeholder="请输入模板名称"
            v-model="templateDataForm.templateName" maxlength="20">
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button :size="size" @click="templateDialogVisible=false" >取消</el-button>
        <el-button :size="size" type="primary" @click.native="saveTemplate">确定</el-button>
      </div>
    </el-dialog>


  </div>

</template>

<script>
import TreeSelect from "@/views/Core/TreeSelect";
import { customerLimitRadio, offeredCustomerLimitRadio, chanelCodesRadio, proPlatformRadio, proUserTypeRadio, proMemberTypeRadio, proMemberLevelRadio } from "@/market/dict/marketDict";
import {formatDate2} from "../../../utils/datetime";


export default {
  components: {
    TreeSelect
  },

  // 渲染后
  created() {
    this.materialQueryTree();
    this.queryTagList();
    this.getTagCategoryList();

    console.log("===mounted=this.promotionId===="+this.promotionId);

    //活动id
    //0-创建-1-编辑；
    this.auth = this.$route.query.auth;



    if (this.$route.query.id != undefined || this.$route.query.id == null) {
      console.log("----------this.$route.query.id:"+this.$route.query.id);
      this.promotionId = this.$route.query.id;
      this.promotion.promotionId = this.promotionId ;
      this.mainMerchantForm.promotionId = this.promotionId ;
      this.mainStoreMerchantForm.promotionId = this.promotionId;

      console.log("===mounted后=this.promotionId===="+this.promotionId);
      //调用详情
      var param = {};
      param.id = this.promotionId;

      let this_ =this;
      let callback = res => {
        console.log(res);
        if (res.code == "0000") {
          this.filters.id = res.data.id;
          this.filters.promName = res.data.promName;
          // this.filters.startTime = res.data.startTime;
          // this.filters.endTime = res.data.endTime;
          // this_.filters.promotionStartEndTime[0] = new Date(res.data.startTime);
          // this_.filters.promotionStartEndTime[1] = new Date(res.data.endTime);
          this.filters.preheatTime = res.data.preheatTime;
          this.filters.promotionStartEndTime =[];
          this.filters.promotionStartEndTime.push(new Date(res.data.startTime));
          this.filters.promotionStartEndTime.push(new Date(res.data.endTime));

          this.filters.groupTimeType = res.data.groupTimeType.toString();
          if(this.filters.groupTimeType=="1"){
            this.filters.groupTimeLimit = res.data.groupTimeLimit;
          }
          this.filters.autoCompleteTime = res.data.autoCompleteTime;
          this.filters.individualJoinType = res.data.individualJoinType.toString();
          this.filters.individualJoinTime = res.data.individualJoinTime;
          this.filters.proUserType = (res.data.proUserType + "").split("|");
          this.handleCheckedCitiesChange2(this.filters.proUserType);

          this.filters.mailType = res.data.mailType.toString();
          this.filters.groupMembers = res.data.groupMembers;
          this.filters.groupType = res.data.groupType.toString();
          this.filters.customerLimit = (res.data.customerLimit + "").split("|");
          this.handleCheckedCitiesChange9(this.filters.customerLimit);

          this.filters.offeredCustomerLimit = (res.data.offeredCustomerLimit + "").split("|");
          this.handleCheckedCitiesChange10(this.filters.offeredCustomerLimit);

          this.filters.costAllocationFlag = res.data.costAllocationFlag;
          this.filters.parentAllocationScale = res.data.parentAllocationScale;
          this.filters.childAllocationScale = res.data.childAllocationScale;
          this.filters.merchantAllocationScale = res.data.merchantAllocationScale;
          this.filters.storeAllocationScale = res.data.storeAllocationScale;

          this.filters.labelId = Number(res.data.labelId);

          this.filters.remark = res.data.remark;
        } else {

        }
      };

      this.utils.request.patchGrouponDetail(param, callback);
    }

  },
    // vue 数据
    data(){
        //是否分摊活动验证
        let checkCostAllocationFlag= (rule, value, callback) => {
          if (!value) {
            return callback(new Error('请选择是否分摊'));
          } else{
            if(value == 1){
              var parentAllocationScale = this.filters.parentAllocationScale;//母平台分摊比例
              var childAllocationScale = this.filters.childAllocationScale;//子平台分摊比例
              var merchantAllocationScale = this.filters.merchantAllocationScale;//商家分摊比例
              var storeAllocationScale = this.filters.storeAllocationScale;//店铺分摊比例
              if(parentAllocationScale == null || parentAllocationScale == '' ) {
                callback(new Error('请输入母平台分摊比例'));
              }else if(childAllocationScale == null || childAllocationScale == '' ) {
                callback(new Error('请输入子平台分摊比例'));
              }else if(merchantAllocationScale == null || merchantAllocationScale == '' ) {
                callback(new Error('请输入商家分摊比例'));
              }else if(storeAllocationScale == null || storeAllocationScale == '' ) {
                callback(new Error('请输入店铺分摊比例'));
              }else if (!Number.isInteger(parentAllocationScale) || !Number.isInteger(childAllocationScale)
                || !Number.isInteger(merchantAllocationScale)  || !Number.isInteger(storeAllocationScale) ) {
                callback(new Error('请输入数字值'));
              } else {
                if (Number(parentAllocationScale) +  Number(childAllocationScale)
                  + Number(merchantAllocationScale) + Number(storeAllocationScale)!=100 ) {
                  callback(new Error('母平台、子平台、商家、店铺分摊比例总和为100'));
                } else {
                  callback();
                }
              }
            } else {
              callback();
            }
          }
        };

        // 拼团人数验证
        let checkGroupMembersCount= (rule, value, callback) => {
          if(value <= 1){
            return callback(new Error('拼团人数必须大于1'));
          }
        };

        // 验证模板名称的函数
        let validateTemplateName = (rule, value, callback) => {
          // 当模板名称为空值且为必填时，抛出错误，反之通过校验
          if (this.filters.templateName === "" && this.templateNameRequired) {
            callback(new Error("请输入模板名称"));
          } else {
            callback();
          }
        };

        let checkTagName = (rule, value, callback) => {
          let regEn = /[`~!@#$%^&*()_+<>?:"{},.\/;'[\]]/im,
            regCn = /[·！#￥（——）：；“”‘、，|《。》？、【】[\]]/im;
          if(regEn.test(value) || regCn.test(value)) {
            callback(new Error('名称不能包含特殊字符'));
          }
          callback();
        };


      let checkCNEnNum = (rule, value, callback) => {
        let regChar = /^[\u4E00-\u9FA5A-Za-z0-9]+$/;
        if(!regChar.test(value)) {
          callback(new Error('仅支持中英文数字'));
        }
        callback();
      };

        return{
          formLabelWidth: '120px',
          // 活动时间校验
          startTimePickerOptions: {
            disabledDate: time => {
              // if (this.filters.endTime) {
              //   return time.getTime() < Date.now() - 8.64e7 || time.getTime() > new Date(this.filters.endTime).getTime()
              // } else {
                return time.getTime() < Date.now() - 8.64e7
              // }
            }
          },

          isIndeterminate: true,
          isIndeterminate1: true,
          isIndeterminate2: false,
          isIndeterminate3: true,
          isIndeterminate4: true,


          isIndeterminate9: false,
          isIndeterminate10: false,

          checkAll2: false,
          checkAll9: false,
          checkAll10: false,


          // 用户类型
          proUserTypeRadios: proUserTypeRadio,
          customerLimitRadios: customerLimitRadio,
          offeredCustomerLimitRadios: offeredCustomerLimitRadio,

          // ----  标签相关实体  开始 ------
          tagsList:[],
          addTagDialogFormVisible: false,
          addTagForm:{
            categoryId: null,
            tagName:null,
          },
          addTagRules:{
            categoryId:[{ required: true, message:"请选择标签分类", trigger: "change"}],
            tagName:[
              { required: true, message:"请输入标签名称", trigger: "blur"},
              { min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur'},
              { trigger: 'blur', validator:checkTagName}
            ],
          },
          templateDataFormRule:{
            templateName:[{ required: true, message:"请输入模板名称", trigger: "blur"}],
          },
          tagCategoryList:[],

          // ----  标签相关实体 结束 ------

          // -------   上传图片相关实体 开始  -------
          uploadMethodVisible: false,
          showFileList:false, //是否显示文件列表
          imgUrlList: [],//图片上传
          autoUpload: true,//图片自动上传
          materialLibraryVisible: false,
          materialImgNumber:0,//选择素材数
          localTreeList:[],//本地树
          deptTreeList:[],//平台树
          defaultProps: {
            children: 'treeInfoList',
            label: 'categoryName'
          },
          //treeActiveName
          treeActiveName:"1",
          //查询素材列表分页
          materialQueryPageFilters:{
            start: 1,
            limit: 10,
            materialName: null
          },
          //素材分类tabs选项卡是否自动撑开
          stretch: true,
          //素材列表页title
          materialTitle: '',
          //素材List
          materialList:[],
          materialListTotal:0,//素材列表总条数




          // -------  上传图片相关实体 结束  -------

          channelList:[{
            channelName:"母平台",
            id:1,
            children:[{
              channelName:"子平台1",
              id:2
            },{
              channelName:"子平台2",
              id:3
            }]
          }],//渠道Tree List
          channlProps:{
            label: 'channelName'
          },
          labelPosition: 'right',
          // 模板名称必填项目
          templateNameRequired :false,
          // groupDisabled:true,
          adminDataForm:{
            auditRemark:""
          },

          adminDataFormRules : {
            auditRemark : [{ required: true, message: "审核意见不能为空！", trigger: "change" }]
          },
          dialogVisibleAdmin: false,
            shenhe:0,
            options:[
                {
                    label:"食品",
                    children:[{
                        label:"乳制品",
                        children:[{
                            label:"乳制品-外国",
                        }]
                    }]
                }
            ],
            selectedOptions:[],
            formInline:{
                商品类目:"1",
                商品品牌:"1",
                start:1,
                limit:10,
                productName:"",
                productNo:"",
                barCode:"",
            },

          // step3--start

          tableDataTwo:[],
          productListTotal:0,
          productListloading:true,
          merchantProductTableData: [],
          merchantProductTableDataTotal:0,
          dialogVisibleTwo:false,
          tabsIndex:'first',
          productForm:{
            id:"",
            start:1,
            limit:10,
            productName:"",
            productNo:"",
            barCode:"",
            chineseName:"",
            merchantName:"",
            storeName:"",
            code:""
          },

          searchMerchantProductFlag: false,
          editMerchantProductFlag: false,
          // step3--end

            dialogImageUrl: '',
            dialogVisible: false,
            size:"mini",
            active:1,
            dataForm:{
                团单时长:"1",
                单用户参团限制:"1",
                是否包邮:"1",
                拼团模式:"1",
                活动渠道:"1",
                开团活动对象:"1",
                参团活动对象:"1",
            },
            // 第一步数据验证
            dataFormRules: {
                // preheatTime: [{type: 'integer', message: '请输入整数类型', trigger: 'change'}],
                promName: [
                  { required: true, message: "请输入拼团名称", trigger: "blur" },
                  {min: 3, max: 60, message: "请输入3-60个字符之间", trigger: "blur" },
                  {validator: checkCNEnNum, message: "仅支持中英文数字", trigger: "blur" }
                  ],
                // startTime: [{ required: true, message: "请选择活动时间", trigger: "change" }],
                // endTime: [{ required: true, message: "请选择活动时间", trigger: "change" }],
                promotionStartEndTime: [{ required: true, message: "请选择活动时间", trigger: "change" }],
                costAllocationFlag: [{ required: true, validator: checkCostAllocationFlag, trigger: 'blur' }],
                groupTimeType: [{ required: true, message: "请选择团单时长", trigger: "blur" }],
                individualJoinType:[{ required: true, message: "请选择单用户参团限制", trigger: "blur" }],
                mailType:[{ required: true, message: "请选择是否包邮", trigger: "change" }],
                groupMembers:[{ required: true, message: "请输入拼团人数", trigger: "blur" }],
                  // { required: true, validator: checkGroupMembersCount, trigger: "blur" }],
                groupType:[{ required: true, message: "请输入拼团模式", trigger: "blur" }],
                proUserType:[{ required: true, message: "请输入新老用户", trigger: "blur" }],
                customerLimit:[{ required: true, message: "请输入开团活动对象", trigger: "blur" }],
                offeredCustomerLimit:[{ required: true, message: "请输入参团活动对象", trigger: "blur" }],
                channelCodes:[{ required: true, message: "请输入渠道对象", trigger: "blur" }],
                templateName:[{ validator: validateTemplateName, trigger: "blur" }],
                remark: [{max: 1000, message: "请输入1000个字符以内", trigger: "blur" }],
            },
            // 第一步提交FullPromotionCreate
            filters: {
              // "promType":1,//单一促销
              "promName": "",
              "frontPromType": 2,
              "preheatTime": null,
              "templateSaveFlag": false,
              "templateName": "",
              "overLimitRule": 2,
              "channelCodes": [],
              "customerLimit": [],
              "offeredCustomerLimit": [],
              "remark": "",
              "promPlatform": null,
              "proUserType": [],
              "proMemberType": null,
              "proMemberLevel": null,
              // "createMerchantId":11,
              // "createMerchantName":"",
              "contentType":1,
              // "creator":1,
              // "creatorName":"admin",
              // "updator":1,
              // "updatorName":"admin",
              "groupMembers":"",
              "groupType":"0",
              "groupTimeType":"0",
              "groupTimeLimit":"",
              "autoCompleteTime":"",
              "individualJoinType":"0",
              "individualJoinTime":"",
              "mailType":"0",
              "promotionStartEndTime":[],
              "startTime": "",
              "endTime": "",
              "storeArea": 3,
              "userArea": 3,
              "channelIds":[],
              "labelId":null,
              "costAllocationFlag": "1",
              "parentAllocationScale": null,
              "childAllocationScale": null,
              "merchantAllocationScale": null,
              "storeAllocationScale": null,

              "fileUrl":null
            },
          //-----------step2###start

          //第一步添加成功赋值
          //外部赋值-----------------start
          promotionId:null,
          auth:0,
          //外部赋值-----------------start

          promotion:{
            //促销id
            id:"",
            promotionId: this.promotionId,
            merchantType:"1",
          },
          pomotionListObject:{pomotionList:[]},
          mainMerchantForm:{
            promotionId: this.promotionId,
            merchantType:"1",
            pageNo:1,
            pageSize:10,
            orderBys:{
              "f":"create_time",
              "s":"desc"
            }
          },
          mainMerchantTableDataTatol: 0,
          merchantForm: {
            // orgNumber:null,
            // name:null,
            start:1,
            limit:10,
          },
          merchantTableDataTatol: 0,
          merchantTableData: [
          ],
          //选择的商家列表
          merchantTableData2: [
          ],
          storeForm:{
            start:1,
            limit:10,
            merchantIds:"",
            storeName:"",
            storeId:""
          },

          mainStoreMerchantForm:{
            promotionId: this.promotionId,
            merchantType:"2",
            pageNo:1,
            pageSize:10,
            orderBys:{
              "f":"create_time",
              "s":"desc"
            }
          },
          storeTableDataTatol: 0,
          storeTableData:[
          ],
          //选择店铺
          storeTableData2Total:0,
          storeTableData2: [],
          //选择店铺
          addSelectionStoreTableData2: [],
          merchantTableData2Selection:[],
          merchantTableData2SelectionIndex:0,
          storeTableDataSelection:[],
          storeTableDataSelectionIndex:0,
          editDialogVisible:false,
          editDialogVisible2:false,
          //-----------step2###end

          // -------------------属性商品开始-----------------------------
          productAddSelection: [],
          productPromotionListObject :{productPromotionList:[]},

          mainProductAddSelection: [],
          mainProductListObject :{mainProductList:[]},

          productEditLoading: false,

          mainProductForm:{
            merchantId: null,
            mpCode: null,
            mpName: null,
            categoryName: null,
            promotionId: null,
            start:1,
            limit:10,
            orderBys:{
              "f":"create_time",
              "s":"desc"
            }
          },

          limitNum: 1,  // 上传excell时，同时允许上传的最大数
          fileList: [],   // excel文件列表

        // --------------------------第四步数据----------------------------------
          saveTemplateFlag: 0,

          templateDataForm: {
            templateName: '',
          },
          templateDialogVisible: false,
        }
    },
    methods: {

      // -------  step1  开始 -------

      /**
       * 子母平台分摊监听
       */
      keyupCost(val,flag){
        let checkNumber = /^\d{3}$/;
      },

      // ---- 开团活动对象  开始  ----
      handleCheckAllChange9(val) {
        this.filters.customerLimit = val ? customerLimitRadio.map(function(value,index,array){return value.code}) : [];
        this.isIndeterminate9 = false;
      },
      handleCheckedCitiesChange9(value) {
        let checkedCount = value.length;
        this.checkAll9 = checkedCount === this.customerLimitRadios.length;
        this.isIndeterminate9 =
          checkedCount > 0 && checkedCount < this.customerLimitRadios.length;
      },
      // ---- 开团活动对象  结束  ----


      // ---- 参团活动对象  开始  ----
      handleCheckAllChange10(val) {
        this.filters.offeredCustomerLimit = val ? offeredCustomerLimitRadio.map(function(value,index,array){return value.code}) : [];
        this.isIndeterminate10 = false;
      },
      handleCheckedCitiesChange10(value) {
        let checkedCount = value.length;
        this.checkAll10 = checkedCount === this.offeredCustomerLimitRadios.length;
        this.isIndeterminate10 =
          checkedCount > 0 && checkedCount < this.offeredCustomerLimitRadios.length;
      },
      // ---- 参团活动对象  结束  ----

      // ---- 新老用户  开始  ----
      handleCheckAllChange2(val) {
        this.filters.proUserType = val ? proUserTypeRadio.map(function(value,index,array){return value.code}) : [];
        this.isIndeterminate2 = false;
      },
      handleCheckedCitiesChange2(value) {
        let checkedCount = value.length;
        this.checkAll2 = checkedCount === this.proUserTypeRadios.length;
        this.isIndeterminate2 =
          checkedCount > 0 && checkedCount < this.proUserTypeRadios.length;
      },
      // ---- 新老用户  结束  ----

      //  ----- 标签相关方法 开始 ------
      /**
       * 查询标签List
       */
      queryTagList(id){
        let that = this;
        this.utils.request.getTagList({},res=>{
          this.tagsList = res.data.rows;
          if(id != null){
            this.filters.labelId = id;
          }
        })
      },
      /**
       * 标签分类查询
       */
      getTagCategoryList(){
        let that = this;
        this.utils.request.getTagCategoryList({},res=>{
          this.tagCategoryList = res.data.rows;
        })
      },

      /**
       * 新增标签弹窗
       */
      addtags(){
        if(this.$refs["addTagForm"] != undefined){
          this.$refs["addTagForm"].resetFields();
        }
        this.addTagDialogFormVisible = true;
      },
      /**
       * 新增标签
       */
      addNewTag(){
        this.$refs["addTagForm"].validate((valid) => {
          if (valid) {
            //TODO 新增标签
            // this.addTagForm
            let that = this;
            this.utils.request.addTag(this.addTagForm,res=>{
              that.queryTagList(res.data);
              that.addTagDialogFormVisible = false;
            })

          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      // ----- 标签相关方法 结束 ------
      /**
       * 渠道选择
       */
      channelCheckChange(data, checked, indeterminate){
        console.log(data, checked, indeterminate);
        let index = this.filters.channelCodes.indexOf(data.id);
        if(index != -1){
          //存在
          this.filters.channelCodes.splice(index,1);
        }else{
          //不存在
          this.filters.channelCodes.push(data.id);
        }
        console.log("===========>>>>>"+JSON.stringify(this.filters.channelCodes));
      },

      // 清除上次的校验提示
      clearValidateProp(formName, prop) {
        this.$refs[formName].clearValidate(prop);
      },
      // 设置需要保存模板
      setTemplateSaveFlag(val){
        let this_ = this;
        if (val){
          console.log("=====设置需要保存模板=====",val);
          this_.templateNameRequired = true;
        } else {
          this_.clearValidateProp('filters','templateName');
          this_.templateNameRequired = false;
        }
      },
      // ------   上传图片相关方法  开始    -------
      /**
       * 本地上传图片成功回调
       */
      imgUploadSuccess(response, file, fileList){
        // debugger
        this.imgUrlList.push({url:URL.createObjectURL(file.raw), hover:null})
        this.uploadMethodVisible = false;
      },
      imgUploadError(err, file, fileList){
        this.$message({message:"文件上传失败,请重新上传", type:"error"})
      },
      /**
       * 选择上传方式弹窗
       */
      selectUploadMethod(){
        this.uploadMethodVisible = true;
      },
      /**
       * 鼠标移入
       */
      mouseEnter(index){
        // debugger
        this.imgUrlList[index].hover = true;
      },
      /**
       * 鼠标移出
       */
      mouseLeave(index){
        // debugger
        this.imgUrlList[index].hover = null;
      },

      /**
       * delete图片列表
       */
      deleteImgUrlList(index){
        this.imgUrlList.splice(index,1);
      },


      uploadMethod(val){
        console.log(val);
        let param = new FormData();
        param.append("name", "wiiiiiinney");
        //通过append向form对象添加数据
        param.append("file", val.file);
        //FormData私有类对象，访问不到，可以通过get判断值是否传进去
        console.log(param.get("file"));
        this.utils.request.upload(param);
      },


      // ------   素材相关方法  -------

      /**
       * 查询素材树
       */
      materialQueryTree(){
        let that = this;
        this.utils.request.materialQueryTree({},res=>{
          this.deptTreeList = res.data.deptTreeList;
          this.localTreeList = res.data.localTreeList;
        })
      },

      /**
       * 菜单树选项卡
       */
      handleClick(val){

      },

      /**
       * 菜单树选项卡
       */
      handleNodeClick(data){
        if(data != undefined && data.id != null){
          this.materialQueryPageFilters.materialName = null;
        }
        console.log(data);
        this.materialTitle = data != undefined && data.categoryName != null ? data.categoryName : this.materialTitle;
        this.materialQueryPageFilters.categoryId = data != undefined && data.id != null ? data.id : this.materialQueryPageFilters.categoryId;
        this.materialQueryPageFilters.materialName = this.materialQueryPageFilters.materialName == '' ? null : this.materialQueryPageFilters.materialName;
        this.utils.request.materialQueryPage(this.materialQueryPageFilters,res=>{
          console.log(res);
          res.data.rows.forEach(item => {
            item.isSelect  = false;
          })
          this.materialList = res.data.rows;
          this.materialListTotal = res.data.total;
        })
      },

      /**
       * 换页
       */
      handleCurrentChange(val){
        this.materialQueryPageFilters.start = val;
        this.handleNodeClick(undefined);
      },

      /**
       * 素材列表条数
       */
      handleSizeChange(val){
        this.materialQueryPageFilters.limit = val;
        this.handleNodeClick(undefined);
      },


      /**
       * 素材确认
       */
      addMaterial(){
        let flag = true;
        this.materialList.forEach(item=>{
          if(item.isSelect){
            flag = false;
            this.imgUrlList.push({url:item.materialUrl, hover:null})
          }
        })
        if(flag){
          this.$message({message:"请选择要选用素材", type:"warning"})
          return false;
        }
        this.materialLibraryVisible = false;
        this.uploadMethodVisible = false;
        this.$message({message:"选用成功", type:"success"})
      },

      // ------   上传图片相关方法  结束    -------

      detailList(){
        this.$router.push({
          path: `/pages/promotionManagement/createGroupon`,
        })
      },
      submitFormAdminNotPass(){
        let callback = res => {
          console.log(res);
          if (res.code == "0000") {

          }
        };
        this.adminDataForm.id = this.promotionId;
        //  更新活动状态  审核不通过
        // 7 -> 4  活动状态
        this.adminDataForm.status = 4;
        this.$refs['adminDataForm'].validate(valid => {
          if (valid) {
            this.utils.request.patchGrouponUpdate(this.adminDataForm, callback);
            // 去掉审核按钮
            this.shenhe = 2;
            this.dialogVisibleAdmin = false;
          }
        });


      },
      submitFormAdmin(){
        this.dialogVisibleAdmin = false;

        let callback = res => {
          console.log(res);
            if (res.code == "0000") {

            }
        };
        this.adminDataForm.id = this.promotionId;
        //  更新活动状态  未开始
        //  4 ->  3 活动状态
        this.adminDataForm.status = 3;
        this.utils.request.patchGrouponUpdate(this.adminDataForm, callback);

        // 去掉审核按钮
        this.shenhe = 2;
      },

      //------step2###start

      resetForm(formName) {
        console.log('--------------'+formName);
        if (this.$refs[formName] != undefined) {
          this.$refs[formName].resetFields();
        }
      },

      //批量删除店铺
      delAllSelectedSupplierstoreTableData(){
        if (this.storeTableDataSelection.length == 0){
          this.$message({message: "未选择删除条目", type: "error"});
          return;
        }

        this.$confirm("确认删除选中记录吗？", "提示", {
          type: "warning"
        })
          .then(() => {
            let ids = this.storeTableDataSelection.map(item => item.id).toString();
            let idArray = (ids + "").split(",");
            this.delAllSelectedSupplierstoreTableDataQueryList(idArray);
          })
          .catch(() => {
          });
      },
      delAllSelectedSupplierstoreTableDataQueryList(idArray){
        let that = this;
        this.promotion.merchantType = "2";
        this.promotion.id = idArray[this.storeTableDataSelectionIndex];
        this.utils.request.promotionMerchantDeleteById2(this.promotion, function(){
          that.storeTableDataSelectionIndex++;
          if(that.storeTableDataSelectionIndex<=idArray.length){
            that.delAllSelectedSupplierstoreTableDataQueryList(idArray)
          }else{
            //执行成功
            that.storeTableDataSelectionIndex = 0;
            that.$message({message: "删除成功", type: "success"});
            that.mainStoreTableDataFormFind();
          }
        });
      },
      //批量删除商家
      delAllSelectedSuppliermerchantTableData2() {
        if (this.merchantTableData2Selection.length == 0){
          this.$message({message: "未选择删除条目", type: "error"});
          return;
        }
        // this.merchantTableData2Selection;
        this.$confirm("确认删除选中记录吗？", "提示", {
          type: "warning"
        })
          .then(() => {
            let ids = this.merchantTableData2Selection.map(item => item.id).toString();
            let idArray = (ids + "").split(",");
            this.delAllSelectedSupplierQueryList(idArray);
          })
          .catch(() => {
          });


      },
      delAllSelectedSupplierQueryList(idArray){
        let that = this;
        this.promotion.merchantType = "1";
        this.promotion.id = idArray[this.merchantTableData2SelectionIndex];
        this.utils.request.promotionMerchantDeleteById2(this.promotion, function(){
          that.merchantTableData2SelectionIndex++;
          if(that.merchantTableData2SelectionIndex<=idArray.length){
            that.delAllSelectedSupplierQueryList(idArray)
          }else{
            //执行成功
            that.merchantTableData2SelectionIndex = 0;
            that.$message({message: "删除成功", type: "success"});
            that.mainMerchantFormFind();
          }
        });
      },
      //添加商家
      querySupplierListForAdd() {
        this.editDialogVisible = true;
        this.promotion.merchantType=1;
      },
      //添加店铺
      querySupplierListForAdd2() {
        this.editDialogVisible2 = true;
        this.promotion.merchantType=2;
      },
      handleCheckChange(data, checked, indeterminate) {
        console.log(data, checked, indeterminate);
        console.log(this.$refs.selectTree);
      },
      //查询店铺
      storeFormFind(){
        //商家 取出商家id-->merchantId
        // this.merchantTableData2;


        let ids = this.merchantTableData2.map(item => item.merchantId).toString();

        console.log("----ids");
        console.log(this.merchantTableData2);
        console.log(ids);
        console.log("----ids---2");

        let params = [];
        console.log("----idArray---");
        let idArray = (ids + "").split(",");
        console.log(idArray);
        console.log("----idArray---2");

        for (var i = 0; i < idArray.length; i++) {
          params.push({id: idArray[i]});
        }

        console.log("----params");
        console.log(params);
        console.log("----params--2");



        console.log(this.merchantTableData.length);
        console.log("----");
        console.log(this.merchantTableData);

        // mergeTo = mergeTo.concat(mergeFrom);

        if(this.merchantTableData2.length==0) {
          this.$message({message: "请先选择商家", type: "success"});
          return;
        }

        // this.merchantTableDataTatol;
        this.storeTableData2.splice(0, this.storeTableData2.length);
        var  this__= this;
        this.storeForm.merchantIds = ids;
        this.utils.request.queryByIds(this.storeForm, function (res) {
          console.log(res)
          if (res.code == "0000") {
            // this__.storeTableData2= this__.storeTableData2.concat(res.data);

            this__.storeTableData2= res.data.rows;
            this__.storeTableData2Total = res.data.total;
          }
        });


      },
      storeTableDataselectionChange(val){
        this.storeTableDataSelection=val;
      },
      merchantTableData2selectionChange(val){
        this.merchantTableData2Selection=val;
      },
      //选择店铺
      storeTableData2AddSelectionChange(val){
        this.addSelectionStoreTableData2=val;
      },
      //提交 选择店铺
      storeTableData2Click(){
        console.log(this.addSelectionStoreTableData2);
        // 调添加店铺 关系接口
        this.merchantTableDataSubmit2();
      },
      merchantTableDataSubmit2(){
        // this.merchantTableData2 = this.addSelection;

        let callback = res => {
          console.log(res);
          if (res.code == "0000") {
            this.storeSaveBatch();
          }
        };

        //调接口
        //删除这个活动老的数据
        //批量添加新的数据
        this.promotion.id=null;
        this.promotion.promotionId=this.promotionId;
        this.promotion.merchantType="2";
        this.utils.request.promotionMerchantDeleteByPromotionId2(this.promotion, callback);
      },

      //批量添加店铺
      storeSaveBatch(){
        console.log("storeSaveBatch");
        console.log(this.addSelectionStoreTableData2);
        console.log("storeSaveBatch2");
        this.pomotionListObject.pomotionList.splice(0,this.pomotionListObject.pomotionList.length);
        console.log("storeSaveBatch pomotionList");
        console.log(this.pomotionListObject.pomotionList);
        console.log("storeSaveBatch pomotionList2");

        for (var i = 0; i < this.addSelectionStoreTableData2.length; i++) {
          var temp = {};

          temp.promotionId         = this.promotionId;
          temp.storeId           =  this.addSelectionStoreTableData2[i].id;
          temp.merchantType        = "2";
          temp.storename        = this.addSelectionStoreTableData2[i].storeName;
          temp.storecode =    this.addSelectionStoreTableData2[i].storeCode;
          temp.storeType           =this.addSelectionStoreTableData2[i].storeType;
          temp.merchantName     =this.addSelectionStoreTableData2[i].merchantName;
          temp.merchantId       =this.addSelectionStoreTableData2[i].merchantId;

          this.pomotionListObject.pomotionList.push(temp);
        }
        console.log("storeSaveBatch promotionMerchantSaveBatch2 push ok");
        console.log(this.pomotionListObject.pomotionList);
        console.log("storeSaveBatch promotionMerchantSaveBatch2 push ok2");

        let callback = res => {
          console.log(res);
          if (res.code == "0000") {
            this.mainStoreTableDataFormFind();
          }
        };

        this.utils.request.promotionMerchantSaveBatch2(this.pomotionListObject, callback );

      },
      //查询绑定关系的店铺
      mainStoreTableDataFormFind(){
        // this.storeTableData
        this.mainMerchantForm.merchantType="2";
        this.mainMerchantForm.promotionId=this.promotionId;
        var  this__= this;
        this.utils.request.promotionMerchantList2(this.mainMerchantForm, function (res) {
          console.log(res);
          if (res.code == "0000") {
            var ret = [];
            for (var i = 0; i < res.data.list.length; i++) {
              var temp = {};
              temp.promotionId         = res.data.list[i].promotionId;
              temp.id        = res.data.list[i].id;
              temp.storeId   =  res.data.list[i].storeId;
              temp.storename = res.data.list[i].storename;
              temp.storecode =  res.data.list[i].storecode;
              temp.storeType = res.data.list[i].storeType;

              ret.push(temp);
            }
            //店铺调试
            this__.storeTableData = res.data.list;
            this__.storeTableDataTatol = res.data.totalCount;
          }
        });
      },


      // 换页刷新
      mainSroreMerchantRefreshPageRequest: function (pageNum) {
        this.mainStoreMerchantForm.pageNo = pageNum;
        this.mainStoreTableDataFormFind();
      },
      // 换页刷新
      mainSroreMerchantHandleSizeChange: function (pageSize) {
        this.mainStoreMerchantForm.pageNo = 1;
        this.mainStoreMerchantForm.pageSize = pageSize;
        this.mainStoreTableDataFormFind();
      },


      // 换页刷新
      refreshPageRequestStore: function (pageNum) {
        this.storeForm.start = pageNum;
        // this.merchantFormFind();
        this.storeFormFind();
      },
      // 换页刷新
      handleSizeChangeStore: function (pageSize) {
        // this.merchantForm;
        this.storeForm.limit = pageSize;
        // this.storeForm.start = 1;
        this.storeFormFind();
      },


      // 换页刷新
      refreshPageRequest: function (pageNum) {
        this.merchantForm.start = pageNum;
        this.merchantFormFind();
      },
      // 换页刷新
      merchantHandleSizeChange: function (pageSize) {
        this.merchantForm.limit = pageSize;
        this.merchantForm.start = 1;
        this.merchantFormFind();
      },

      // 换页刷新
      mainMerchantRefreshPageRequest: function (pageNum) {
        this.mainMerchantForm.pageNo = pageNum;
        this.mainMerchantFormFind();
      },
      // 换页刷新
      mainMerchantHandleSizeChange: function (pageSize) {
        this.mainMerchantForm.pageNo = 1;
        this.mainMerchantForm.pageSize = pageSize;
        this.mainMerchantFormFind();
      },
      //查询绑定关系的商家
      mainMerchantFormFind(){
        this.mainMerchantForm.merchantType="1";
        var  this__= this;
        this.mainMerchantForm.promotionId=this.promotionId;
        this.utils.request.promotionMerchantList2(this.mainMerchantForm, function (res) {

          console.log(res);
          if (res.code == "0000") {
            var ret = [];
            for (var i = 0; i < res.data.list.length; i++) {
              var temp = {};
              temp.id                   = res.data.list[i].id;
              temp.merchantName         = res.data.list[i].merchantName;
              temp.orgNumber            = res.data.list[i].orgNumber;
              temp.merchantTypeManager  = res.data.list[i].merchantTypeManager;
              temp.merchantId           = res.data.list[i].merchantId;
              ret.push(temp);
            }

            this__.merchantTableData2 = ret;
            this__.mainMerchantTableDataTatol = res.data.totalCount;
          }
        });
      },
      // 删除店铺
      storeDelete(id){
        console.log("-----删除店铺:-----"+id);
        this.$confirm("确认删除选中记录吗？", "提示", {
          type: "warning"
        })
          .then(() => {
            let callback = res => {
              console.log(res);
              this.mainStoreTableDataFormFind();
              if (res.code == "0000" && res.data=="1") {
                //删除成功再调分页
                this.$message({message: "删除成功", type: "success"});

              }else{
                this.$message({message: "操作失败, " + res.msg, type: "error"});
              }
            };

            this.promotion.id = id;
            this.utils.request.promotionMerchantDeleteById2(this.promotion,callback);
          })
          .catch(() => {
          });
      },

      //删除商家
      merchantTableData2delete(id){
        console.log("-----删除商家:-----"+id);
        this.$confirm("是否确认删除？", "提示", {
          type: "warning"
        })
          .then(() => {
            let callback = res => {
              console.log(res);
              this.mainMerchantFormFind();
              if (res.code == "0000" && res.data=="1") {
                //删除成功再调分页
                this.$message({message: "删除成功", type: "success"});

              }else{
                this.$message({message: "操作失败, " + res.msg, type: "error"});
              }
            };

            this.promotion.id = id;
            this.utils.request.promotionMerchantDeleteById2(this.promotion,callback);
          })
          .catch(() => {
          });
      },
      //选择商家
      addSelectionChange(val) {
        this.addSelection = val;
        console.log(this.addSelection);
      },
      //提交 选择商家
      merchantTableDataSubmit(){
        // this.merchantTableData2 = this.addSelection;
        console.log("======this.promotionId:========"+this.promotionId);
        let callback = res => {
          console.log(res);
          if (res.code == "0000") {
            this.promotionMerchantSaveBatch2();
          }
        };
        //调接口
        //删除这个活动老的数据
        //批量添加新的数据
        this.promotion.id=null;
        this.promotion.promotionId = this.promotionId;
        console.log("======this.active:"+this.active);
        console.log("======this.promotionId:"+this.promotionId);
        this.promotion.merchantType="1";
        this.utils.request.promotionMerchantDeleteByPromotionId2(this.promotion, callback);
      },


      // 批量添加商家
      promotionMerchantSaveBatch2(){
        console.log("promotionMerchantSaveBatch2");
        console.log(this.addSelection);
        console.log("promotionMerchantSaveBatch2");
        this.pomotionListObject.pomotionList.splice(0,this.pomotionListObject.pomotionList.length);
        console.log("pomotionList");
        console.log(this.pomotionListObject.pomotionList);
        console.log("pomotionList2");

        for (var i = 0; i < this.addSelection.length; i++) {
          var temp = {};

          temp.promotionId = this.promotionId;
          temp.merchantId =  this.addSelection[i].id;
          temp.merchantType = "1";
          temp.merchantName = this.addSelection[i].name;
          temp.merchantTypeManager=this.addSelection[i].merchantType;
          temp.orgNumber=this.addSelection[i].orgNumber;
          temp.name = this.addSelection[i].name;

          this.pomotionListObject.pomotionList.push(temp);
        }
        console.log("promotionMerchantSaveBatch2 push ok");
        console.log(this.pomotionListObject.pomotionList);
        console.log("promotionMerchantSaveBatch2 push ok2");

        let callback = res => {
          console.log(res);
          if (res.code == "0000") {
            this.mainMerchantForm.merchantType="1";
            this.mainMerchantFormFind();
          }
        };

        var  this__= this;
        this.utils.request.promotionMerchantSaveBatch2(this.pomotionListObject, callback );

        console.log("----ok");
        console.log(this.merchantTableData2);
        console.log("----ok2");

      },
      //查询商家
      merchantFormFind(){
        console.log("---------查询商家");
        var  this__= this;
        this.utils.request.queryMerchantList(this.merchantForm, function (res) {
          // this.utils.request.queryMerchantListOther(null, function (res) {
          if (res.code == "0000") {
            this__.merchantTableData= res.data.rows;
            this__.merchantTableDataTatol = res.data.total;
          }
        });
      },
      //------step2###end


      // -----------step3-----------方法商品开始-------------------------------

        select(rows){
            console.log("========================"+JSON.stringify(rows));
            this.dialogVisibleTwo = !this.dialogVisibleTwo;
            this.productSave(rows);
        },

      // 查询促销商品
      mainProductTableDataFormFind(startFlag){
        this.mainProductForm.promotionId=this.promotionId;
        console.log("---------"+this.promotionId);
        if (startFlag == undefined || startFlag != 1) {
          this.mainProductForm.start =1;
        }
        let  this_= this;
        this_.utils.request.groupProductList(this.mainProductForm, function (resp) {
          console.log("查询促销商品查询促销商品查询促销商品查询促销商品查询促销商品:"+JSON.stringify(resp));
          if (resp.code == "0000") {
            var ttt = [];
            $.each(resp.data.rows, function (index, value) {

              value.disabled=true;
              ttt.push(value);
            });


            this_.merchantProductTableData = ttt;
            this_.merchantProductTableDataTotal = resp.data.total;
          }
        });
      },


      /**
       * 每页条数刷新
       */
      mainProductHandleSizeChange(val){
        this.mainProductForm.limit = val;
        this.mainProductTableDataFormFind(1);
      },
      /**
       * 换页刷新
       */
      mainProductHandleCurrentChange(val){
        this.mainProductForm.start = val;
        this.mainProductTableDataFormFind(1);
      },


      //删除促销商品-todo
      delMerchantProducts(row, promotionId, mpId){
        console.log("=====删除促销商品:promotionId==="+ promotionId + "==mpId==" + mpId);

        this.$confirm("确认删除选中记录吗？", "提示", {
          type: "warning"
        })
          .then(() => {
            let this_ =this;
            let callback = function(res) {
              if (res.code == "0000") {
                // 成功查询本地促销商品
                console.log(res);
                this_.mainProductTableDataFormFind();
              } else {
                this_.mainProductTableDataFormFind();
                this_.$message({ message: "删除失败", type: "error" });
              }
            };

            let param ={};
            param.mpId                =row.mpId;
            param.promotionId         =row.promotionId;
            this.utils.request.groupProductDelete(param, callback);
          })
          .catch(() => {
            // this_.$message({ message: "已取消", type: "warning" });
          });
      },

        handleChange(myArray) {
            // myArray.every(function (item, index, array) {
            //     let data = CodeToText[item[0]] + ", " + CodeToText[item[1]] + ", " + CodeToText[item[2]];
            //     console.log(data)
            // })
        },

        //table的编辑和删除
        handleEdit(index, row) {
          // this.groupDisabled = !this.groupDisabled;

            // console.log(index, row);
            row.disabled = !row.disabled;
        },

        // 更新价格或者限量
        updatePriceOrLimit(row){
          let jsonVal =JSON.stringify(row);
          console.log("========更新价格或者限量======="+jsonVal);
          let callback = function(res) {
            if (res.code == "0000") {

            } else {
              alert("修改失败");
            }
          };

          let temp = {};
          temp.promotionId              = row.promotionId;
          temp.mpId                     = row.mpId;
          temp.grouponPrice 			= row.grouponPrice;
          temp.individualLimit 			= row.individualLimit;
          temp.channelMerchantLimit 	= row.channelMerchantLimit;
          temp.channelStoreLimit 		= row.channelStoreLimit;

          // console.log("---row.channelMerchantLimit:---"+row.channelMerchantLimit);
          // if(row.channelMerchantLimit < row.channelStoreLimit){
          //   this.$message({
          //     message: '警告哦，这是一条警告消息',
          //     type: 'warning'
          //   });
          //   return;
          // }

          this.utils.request.groupProductUpdate(temp, callback);
        },

        handleSave(index, row){
          console.log(index+'-handleSave-index-');
          console.log(row);
          console.log('-----end----');

          let callback = res => {
            console.log(res);
            if (res.code == "0000") {
              row.disabled = !row.disabled;
            }
          };
          let temp = {};
          temp.promotionId              = row.promotionId;
          temp.mpId                     = row.mpId;
          temp.grouponPrice = row.grouponPrice;
          temp.individualLimit = row.individualLimit;
          temp.channelMerchantLimit = row.channelMerchantLimit;
          temp.channelStoreLimit = row.channelStoreLimit;

          this.utils.request.groupProductUpdate(temp, callback);
        },
        handleDelete(index, row) {
            console.log(index, row);
        },
        handleRemove(file, fileList) {
            console.log(file, fileList);
        },
        handlePictureCardPreview(file) {
            this.filters.fileUrl = file.url;
            this.dialogVisible = true;
        },
        next(){

          // console.log(this.filters.endTime);
          // console.log("00000000000000000000000000000000");
          // if (this.active >= 2) {
          //   this.active = this.active + 1;
          // }

          console.log("--------当前激活步骤------");
          console.log(this.active);
          console.log("--------当前激活步骤------");

          let _this = this;
          let callback = res => {
            console.log("111111111");
            console.log(res);
            console.log("222222222");
            if (res.code == "0000") {
              _this.active = this.active + 1;
              _this.promotionId = res.data;
              _this.promotion.promotionId = res.data;
              _this.mainMerchantForm.promotionId = res.data;
              _this.mainStoreMerchantForm.promotionId = res.data;

              _this.mainMerchantFormFind();
              _this.mainStoreTableDataFormFind();
            } else {
              this.$message({ message: "操作失败", type: "fail" });
              this.active = 1;
            }
          };

          let callbackUpdate = res => {
            console.log("111111111");
            console.log(res);
            console.log("222222222");
            if (res.code == "0000") {
              this.active = this.active + 1;
              this.mainMerchantFormFind();
              this.mainStoreTableDataFormFind();
            } else {
              this.$message({ message: "操作失败", type: "fail" });
              this.active = 1;
            }
          };

          //保存活动基础配置
          if(this.active == 1){
            console.log('----------步骤1-验证-----------');
              this.$refs['filters'].validate(valid => {
                if (valid) {
                  console.log('----------步骤1-grouponSave-----------');
                  this.filters.startTime = this.filters.promotionStartEndTime[0];
                  this.filters.endTime = this.filters.promotionStartEndTime[1];
                  if(this.promotionId == null){

                    this.utils.request.grouponSave(this.filters, callback);
                  }else {
                    this.utils.request.patchGrouponUpdate(this.filters, callbackUpdate);
                  }

                }
              });
          }

          //更新活动状态
          if(this.active==3 || this.active == 4){
            if(this.active == 3 && this.merchantProductTableData.length == 0){
              this.$message({ message: "商品未添加", type: "fail" });
              return;
            }
            let callback = function(res) {
              if (res.code == "0000") {
                _this.addActive();
              } else {
                console.log("修改失败");
                _this.addActive();
              }
            };
            let param ={};
            param.promotionId    =this.promotionId;
            //  更新活动状态  待提交
            // 5 -> 1  活动状态
            param.status         =1;
            this.utils.request.updateGroupPromotionStatus(param,callback);
          }
          if(this.active==2){
            if(this.storeTableData.length == 0 || this.merchantTableData2.length == 0){//判断商家店铺
              _this.$message({ message: "商家或店铺未添加", type: "fail" });
              return;
            };
            this.mainProductTableDataFormFind();
            this.addActive();
          }
          if(this.active==4){
            this.$message({ message: "操作成功", type: "success" });
            return;
          }
        },

        back(){
            this.active = this.active - 1;
        },

        addActive(){
          this.active++;
        },
        // if (this.active++ > 3) this.active = 1;
        // if(this.active++ > 3){
        //   this.$router.push({
        //     path:"/pages/promotionManagement/seckillPromotion"
        //   })
        // }

        viewList(){
          this.$emit("viewList");
        },

      // step3--start

      // 单个添加商品
      productSave(row){
        this.productPromotionListObject.productPromotionList.splice(0,this.productPromotionListObject.productPromotionList.length);

        let temp = {};
        temp.promotionId = this.promotionId;
        temp.mpId = row.id;
        temp.mpName = row.chineseName; // 商品名称
        temp.merchantName = row.name;  //商家名称
        temp.storeName = row.storeName;  //店铺名称
        temp.salePriceWithTax = row.salePriceWithTax;  //零售价
        temp.mpCode = row.code;  //商品编码
        temp.mpParentId = row.parentId;
        temp.merchantId = row.merchantId;
        temp.categoryId = row.categoryId;
        temp.picUrl = row.pictureUrl;
        this.productPromotionListObject.productPromotionList.push(temp);

        let callback = res => {
          console.log(res);
          if (res.code == "0000") {
            // 查询本地促销商品
            this.mainProductTableDataFormFind();
          }
        };

        this.utils.request.groupProductSaveBatch(this.productPromotionListObject, callback );
      },

      //批量添加商品
      productSaveBatch(){
        this.dialogVisibleTwo = !this.dialogVisibleTwo;
        console.log("productSaveBatch");
        console.log(this.productAddSelection);
        console.log("productSaveBatch2");
        this.productPromotionListObject.productPromotionList.splice(0,this.productPromotionListObject.productPromotionList.length);
        console.log("productSaveBatch promotionList");
        console.log(this.productPromotionListObject.productPromotionList);
        console.log("productSaveBatch promotionList2");

        for (let i = 0; i < this.productAddSelection.length; i++) {
          let temp = {};
          temp.promotionId = this.promotionId;
          temp.mpId = this.productAddSelection[i].id;
          temp.mpName = this.productAddSelection[i].chineseName; // 商品名称
          temp.merchantId = this.productAddSelection[i].merchantId;  //商家id
          temp.merchantName = this.productAddSelection[i].merchantName;  //商家名称
          temp.storeName = this.productAddSelection[i].storeName;  //店铺名称
          temp.salePriceWithTax = this.productAddSelection[i].salePriceWithTax;  //零售价
          temp.mpCode = this.productAddSelection[i].code;  //商品编码
          temp.mpParentId = this.productAddSelection[i].parentId;
          temp.merchantId = this.productAddSelection[i].merchantId;
          temp.categoryId = this.productAddSelection[i].categoryId;
          temp.categoryName     = this.productAddSelection[i].fullNamePath;    // 类别名称
          temp.picUrl = this.productAddSelection[i].pictureUrl;
          this.productPromotionListObject.productPromotionList.push(temp);
        }
        console.log("productSaveBatch productPromotionSaveBatch push ok");
        console.log("======================"+JSON.stringify(this.productPromotionListObject.productPromotionList));
        console.log("productSaveBatch productPromotionSaveBatch push ok2");

        let callback = res => {
          console.log(res);
          if (res.code == "0000") {
            // 查询本地促销商品
            this.mainProductTableDataFormFind();
          }
        };

        this.utils.request.groupProductSaveBatch(this.productPromotionListObject, callback );

      },
      productTableDataSubmit2(){

        this.productSaveBatch();
      },
      //确定 选择商品
      productTableData2Click(){
        // console.log("======选择商品======"+this.productAddSelection);
        // // 调添加商品 接口
        // this.productTableDataSubmit2();
      },

      /**
       * 确认添加商品
       */
      addProductChange(val){
        let flag = true;
        this.merchantProductTableData.forEach(res=>{
          this.productAddSelection.forEach(item=>{
            // debugger
            if(res.id == item.id){
              flag = false;
            }
          })
        })
        if(!flag){
          this.$message({ message: "不能添加重复商品", type: "error" });
          return false;
        }

        this.productSaveBatch();
        // if(flag){
        //   // this.tableData.push(row);
        //   this.merchantProductTableData = this.merchantProductTableData.concat(this.productAddSelection);
        //   this.dialogVisibleTwo = !this.dialogVisibleTwo;
        //   this.productAddSelection = [];
        // }
      },

      // 选择商品
      addSelectionChangeProduct(val) {
        let this_ =this;
        this_.productAddSelection = val;
        console.log("==========addSelectionChangeProduct 选择商品============"+JSON.stringify(val));
      },

      // 选择促销商品
      addSelectionChangeMainProduct(val) {
        let this_ =this;
        this_.mainProductAddSelection = val;
        console.log("==========addSelectionChangeProduct 选择促销商品============"+JSON.stringify(val));
      },
      //修改table header的背景色
      tableHeaderColor({ row, column, rowIndex, columnIndex }) {
        if (rowIndex === 0) {
          return 'background-color:rgb(250,250,250);'
        }
      },
      //table的双色条纹
      tableRowClassName({row, rowIndex}) {
        if (rowIndex === 1) {
          return 'warning-row';
        } else if (rowIndex === 3) {
          return 'success-row';
        }
        return '';
      },
      add(){
        this.dialogVisibleTwo = true;
      },
        // 查询商品开始
      productFormFind(){
        let that_ =this;
        that_.productListloading = true;
        that_.utils.request.queryPageProductManagement(this.productForm, function (resp) {
          console.log("======查询商品====="+resp);
          that_.productListloading = false;
          if (resp.code == "0000") {
            that_.tableDataTwo= resp.data.rows;
            that_.productListTotal = resp.data.total;
          }
        });
      },

      /**
       * 条数刷新
       */
      producthandleSizeChange(val){
        this.productForm.limit = 1;
        this.productForm.limit = val;
        this.productFormFind();
      },
      /**
       * 换页刷新
       */
      producthandleCurrentChange(val){
        this.productForm.start = val;
        this.productFormFind();
      },



      //批量删除促销商品
      promotionProductDeleteBatch(){
        if (this.mainProductAddSelection.length == 0){
          this.$message({message: "未选择删除条目", type: "error"});
          return;
        }

        console.log("mainProductDeleteBatch");
        console.log(this.mainProductAddSelection);
        console.log("mainProductDeleteBatch");
        this.mainProductListObject.mainProductList.splice(0,this.mainProductListObject.mainProductList.length);
        console.log("mainProductDeleteBatch promotionList");
        console.log(this.mainProductListObject.mainProductList);
        console.log("mainProductDeleteBatch promotionList2");

        for (let i = 0; i < this.mainProductAddSelection.length; i++) {
          let temp = {};
          temp.promotionId = this.mainProductAddSelection[i].promotionId;
          temp.mpId = this.mainProductAddSelection[i].mpId;
          this.mainProductListObject.mainProductList.push(temp);
        }
        console.log("mainProductDeleteBatch push ok");
        console.log("======================"+JSON.stringify(this.mainProductListObject.mainProductList));
        console.log("mainProductProductDeleteBatch push ok2");

        let callback = res => {
          console.log(res);
          if (res.code == "0000") {
            // 查询本地促销商品
            this.mainProductTableDataFormFind();
          }
        };

        this.$confirm("确认删除选中记录吗？", "提示", {
          type: "warning"
        })
          .then(() => {
            this.utils.request.groupProductDeleteProductBatch(this.mainProductListObject, callback );
          })
          .catch(() => {
          });
      },

      // 导入促销商品
      // 文件超出个数限制时的钩子
      exceedFile(files, fileList) {
        this.$message.warning(`只能选择 ${this.limitNum} 个文件，当前共选择了 ${files.length + fileList.length} 个`);
      },
      // 文件状态改变时的钩子
      fileChange(file, fileList) {
        console.log(file.raw);
        this.fileList.push(file.raw) ;
        console.log(this.fileList);
      },
      // 上传文件之前的钩子, 参数为上传的文件,若返回 false 或者返回 Promise 且被 reject，则停止上传
      beforeUploadFile(file) {
        console.log('before upload');
        console.log(file);
        let extension = file.name.substring(file.name.lastIndexOf('.')+1);
        let size = file.size / 1024 / 1024;
        if(extension !== 'xlsx') {
          this.$message.warning('只能上传后缀是.xlsx的文件');
        }
        if(size > 10) {
          this.$message.warning('文件大小不得超过10M');
        }
      },
      // 文件上传成功时的钩子
      handleSuccess(res, file, fileList) {
        this.$message.success('文件上传成功');
      },
      // 文件上传失败时的钩子
      handleError(err, file, fileList) {
        this.$message.error('文件上传失败');
      },
      UploadUrl:function(){
        // 因为action参数是必填项，我们使用二次确认进行文件上传时，直接填上传文件的url会因为没有参数导致api报404，所以这里将action设置为一个返回为空的方法就行，避免抛错
        return ""
      },
      uploadFile() {
        if (this.fileList.length === 0){
          this.$message.warning('请上传文件');
        } else {
          let form = new FormData();
          form.append('file', this.fileList);
          this.$axios({
            method:"post",
            url: "http://localhost:8087/jic-market/product/groupon/importExcel",
            headers:{
              'Content-type': 'multipart/form-data'
            },
            data:form
          }).then(
            res=>{

            },err =>{
            });
        }
      },

      // step3--end

      // step4--start

      closedAuditDialog(){
        console.log("-------关闭审核对话框时----------");
        this.clearValidateProp('adminDataForm','auditRemark');
      },

        shenheHuodong(flag){
            // 提交审核
            if(flag == 0){

              this.$confirm("是否确认提交审核？", "提示", {
                type: "warning"
              })
                .then(() => {
                  this.shenhe = 1;

                  let callback = res => {
                    console.log(res);
                  };
                  let param ={};
                  param.promotionId    =this.promotionId;
                  //  更新活动状态  待审核
                  //  6 ->2 活动状态
                  param.status         =2;
                  this.utils.request.updateGroupPromotionStatus(param,callback);

                })
                .catch(() => {
                });
              //  审核弹框
            }else{
                // this.shenhe = 2;
                this.dialogVisibleAdmin = true;
              //
              // let callback = res => {
              //   if (res.code == "0000" && res.data=="1") {
              //     this.$message({message: "已提交申请", type: "success"});
              //     this.$router.push({
              //       path: `/pages/promotionManagement/createGroupon`,
              //     })
              //
              //   }else{
              //     this.$message({message: "操作失败, " + res.msg, type: "error"});
              //   }
              // };
              // let param ={};
              // param.promotionId    =this.promotionId;
              // param.status         =4;
              // this.utils.request.updateGroupPromotionStatus(param,callback);

            }
            // this.$message({ message: "操作成功", type: "success" });
        },

      // 调用保存模板对话框
      saveTemplateModal(){
        this.templateDialogVisible = true;
      },

      //保存模板方法
      saveTemplate(){
        this.$confirm("确认保存为模板吗？", "提示", {
          type: "warning"
        })
          .then(() => {
            let this_ = this;
            let params = Object.assign({}, this_.templateDataForm);
            if(params.templateName == null || params.templateName.trim() == ''){
              this_.$message({message:'模板名称不能为空',type:'error'});return;
            }
            params.promotionId=this.promotionId;
            this.utils.request.grouponSaveTemplate(params, function(res){
              if(res.code == '0000'){
                this_.saveTemplateFlag = 1;
                this_.$message({message: "操作成功", type: "success"});
                this_.templateDialogVisible=false;
              }else{
                this_.$message({message: "操作失败", type: "error"});
              }
            });
          })
          .catch(() => {
          });
      },

    },

}
</script>

<style scoped>

  /** 上传图片css开始 **/
  .img-card{
    width: 140px;
    height: 140px;
    line-height: 140px;
    margin-left: 10px;
    margin-top: 10px;
    position: relative;
    cursor: pointer;
  }
  .img-card-upload{
    width: 140px;
    height: 140px;
    line-height: 130px;
    margin-left: 10px;
    margin-top: 10px;
    margin-bottom: 10px;
  }
  /**
     修改element上传组件样式
  */
  .el-upload-dragger-update{
    text-align: center;
    margin-left: -10px;
    margin-bottom: 20px;
  }
  .el-upload-dragger-update /deep/ .el-upload .el-upload-dragger{
    border: 0px;
    /* width: 100px; */
    height: 42px;
  }

  .el-upload-list-item-actions {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    cursor: default;
    text-align: center;
    color: #fff;
    /* opacity: 0; */
    display: none;
    font-size: 20px;
    background-color: rgba(0,0,0,.5);
    transition: opacity .3s;
  }
  .el-upload-list-item-actions-hover{
    display: block;
  }
  .upload-delete{
    cursor: pointer;
  }

  /** 上传图片css结束 **/


  /deep/
    .content{
        padding: 10px;
        font-size: 14px;
        color: #666666;
        background-color: #fff;
        padding-bottom: 100px;
    }
    .title{
        font-weight: 700;
        border-left: 4px solid #ddd;
        padding-left: 10px;
    }
    .item{
        padding-left: 10%;
        /* width: 100%; */
    }
    .input{
        height: 28px !important;
        line-height: 28px !important;
        -webkit-appearance: none;
        background-color: #FFF;
        background-image: none;
        border-radius: 4px;
        border: 1px solid #DCDFE6;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        color: #606266;
        display: inline-block;
        font-size: inherit;
        height: 40px;
        line-height: 40px;
        outline: 0;
        padding: 0 15px;
        font: 400 13.3333px Arial;
        -webkit-transition: border-color .2s cubic-bezier(.645,.045,.355,1);
        transition: border-color .2s cubic-bezier(.645,.045,.355,1);
        width: 30%;
    }
    .bottom-btn{
        position: fixed;
        bottom: 0px;
        width: 100%;
        height: 30px;
        line-height: 30px;
        padding-left: 40%;
        background-color: #fff;
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
        padding-bottom: 30px;
        padding-top: 30px;
        z-index: 4;
    }
    .pointer-input /deep/ input{
        cursor: pointer;
    }
</style>
